Fix exception handling in NextcloudClient#394
Conversation
| return method.execute(this) | ||
| } | ||
|
|
||
| @Throws(IOException::class) |
There was a problem hiding this comment.
@tobiasKaminsky This will proably break clients, but since IOException is checked, it must be handled.
There is no API to return valid Response in case of error, as OkHttp3 use exceptions to signal abnormal condition. We should follow.
There was a problem hiding this comment.
Hm. I would go instead with try/catch so that we can return our own error code.
After all, this is in our library and also should only be called within the library.
There was a problem hiding this comment.
I wrapped the exception in a union-like object.
6276eef to
31a41df
Compare
|
|
||
| class NextcloudClient(var baseUri: Uri, val context: Context) { | ||
| class NextcloudClient(var baseUri: Uri, val context: Context, client: OkHttpClient) { | ||
| lateinit var credentials: String |
There was a problem hiding this comment.
Misused lateinit. This should be initialized here. I'll open another ticket for this, tho.
|
@tobiasKaminsky Could you pealse check the method annotated with |
Codecov Report
@@ Coverage Diff @@
## master #394 +/- ##
==========================================
+ Coverage 37% 37.24% +0.24%
==========================================
Files 133 134 +1
Lines 5737 5751 +14
Branches 751 751
==========================================
+ Hits 2123 2142 +19
+ Misses 3289 3285 -4
+ Partials 325 324 -1
|
31a41df to
78ec45a
Compare
tobiasKaminsky
left a comment
There was a problem hiding this comment.
Extract ResponseOrError
| val client: OkHttpClient | ||
| val client = client | ||
|
|
||
| data class ResponseOrError private constructor(val result: Response?, val error: Exception?) { |
There was a problem hiding this comment.
Nice approach 👍
To not have too many things in one class, can we extract this into its own class?
78ec45a to
eb51e04
Compare
eb51e04 to
220afbb
Compare
|
@tobiasKaminsky I made the |
Fixes #393 Fixes nextcloud/android#5245 Fixes nextcloud/android#5305 Fixes nextcloud/android#5310 Fixes nextcloud/android#5331 Fixes nextcloud/android#5333 Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
220afbb to
803df96
Compare
Lint
SpotBugs (new)
SpotBugs (master)
|
Should be fine, I currently cannot imagine why we need this outside our lib, but we can still change it later, if required. |
Fixes #393
Fixes nextcloud/android#5245
Fixes nextcloud/android#5305
Fixes nextcloud/android#5310
Fixes nextcloud/android#5331
Fixes nextcloud/android#5333
Fixes nextcloud/android#5390
Signed-off-by: Chris Narkiewicz hello@ezaquarii.com